package com.xltt.vehicleControl.bean;

/**
 * @author zhaotengfei
 * @version 1.0.0
 * @created 2017/4/20 17:17
 */

import java.io.Serializable;

public class BasicVehicleStatus implements Serializable {
    private PositionEntity position;
    //速度
    private float speed;
    private int direction;
    private String engineStatus;
    private String keyStatus;
    private String engineBlockedStatus;
    //可续航里程
    private float distanceToEmpty = -1;

    public BasicVehicleStatus() {
    }

    public boolean isEngineStarted() {
        /*
        引擎状态engine-running 启动engine-off 关
        闭unknown 未知
         */
        return "engine_running".equalsIgnoreCase(this.engineStatus);
    }

    public void setPosition(PositionEntity position) {
        this.position = position;
    }

    public void setSpeed(float speed) {
        this.speed = speed;
    }

    public void setDirection(int direction) {
        this.direction = direction;
    }

    public void setEngineStatus(String engineStatus) {
        this.engineStatus = engineStatus;
    }

    public void setKeyStatus(String keyStatus) {
        this.keyStatus = keyStatus;
    }

    public void setEngineBlockedStatus(String engineBlockedStatus) {
        this.engineBlockedStatus = engineBlockedStatus;
    }

    public void setDistanceToEmpty(int distanceToEmpty) {
        this.distanceToEmpty = distanceToEmpty;
    }

    public PositionEntity getPosition() {
        return this.position;
    }

    public float getSpeed() {
        return this.speed;
    }

    public int getDirection() {
        return this.direction;
    }

    public String getEngineStatus() {
        return this.engineStatus;
    }

    public String getKeyStatus() {
        return this.keyStatus;
    }

    public String getEngineBlockedStatus() {
        return this.engineBlockedStatus;
    }

    public int getDistanceToEmpty() {
        return (int) distanceToEmpty;
    }

    public boolean isDistanceToEmptyLow() {
        return this.distanceToEmpty >= 0 && this.distanceToEmpty <= 70;
    }

    public static class PositionEntity implements Serializable {
        private int latitude;
        private int longitude;
        private int altitude;
        private boolean posCanBeTrusted;
        private boolean marsCoordinates;
        private Boolean carLocatorStatUploadEn;

        public PositionEntity() {
        }

        public Boolean getCarLocatorStatUploadEn() {
            return this.carLocatorStatUploadEn;
        }

        public void setCarLocatorStatUploadEn(Boolean carLocatorStatUploadEn) {
            this.carLocatorStatUploadEn = carLocatorStatUploadEn;
        }

        public boolean isMarsCoordinates() {
            return this.marsCoordinates;
        }

        public void setMarsCoordinates(boolean marsCoordinates) {
            this.marsCoordinates = marsCoordinates;
        }

        public void setLatitude(int latitude) {
            this.latitude = latitude;
        }

        public void setLongitude(int longitude) {
            this.longitude = longitude;
        }

        public void setAltitude(int altitude) {
            this.altitude = altitude;
        }

        public void setPosCanBeTrusted(boolean posCanBeTrusted) {
            this.posCanBeTrusted = posCanBeTrusted;
        }

        public int getLatitude() {
            return this.latitude;
        }

        public int getLongitude() {
            return this.longitude;
        }


        public int getAltitude() {
            return this.altitude;
        }

        public boolean isPosCanBeTrusted() {
            return this.posCanBeTrusted;
        }

        public boolean isPositionUpload() {
            return this.carLocatorStatUploadEn == null || this.carLocatorStatUploadEn.booleanValue();
        }

        @Override
        public String toString() {
            return "PositionEntity{" +
                    "latitude=" + latitude +
                    ", longitude=" + longitude +
                    ", altitude=" + altitude +
                    ", posCanBeTrusted=" + posCanBeTrusted +
                    ", marsCoordinates=" + marsCoordinates +
                    ", carLocatorStatUploadEn=" + carLocatorStatUploadEn +
                    '}';
        }
    }

    @Override
    public String toString() {
        return "BasicVehicleStatus{" +
                "position=" + position +
                ", speed=" + speed +
                ", direction=" + direction +
                ", engineStatus='" + engineStatus + '\'' +
                ", keyStatus='" + keyStatus + '\'' +
                ", engineBlockedStatus='" + engineBlockedStatus + '\'' +
                ", distanceToEmpty=" + distanceToEmpty +
                '}';
    }
}
